package com.aop.example.controller;

import com.aop.example.annotation.LogAnnotation;
import com.aop.example.pojo.Test;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/test")
public class TestController {

    @LogAnnotation("system:test:list")
    @GetMapping("/list")
    public List<Test> list(){
        return Arrays.asList(
                new Test("zhangsan","114514"),
                new Test("lisi","1919810")
        );
    }

    @LogAnnotation("system:test:getByName")
    @GetMapping("/getByName/{username}")
    public Test getByName(@PathVariable String username){
        return new Test(username, "测试密码");
    }

    @LogAnnotation("system:test:add")
    @GetMapping("/add/{username}/{password}")
    public Test add(@PathVariable String username, @PathVariable String password){
        return new Test(username, password);
    }

    @LogAnnotation("system:test:del")
    @GetMapping("/del/{username}")
    public String del(@PathVariable String username){
        return "删除成功" + username;
    }
}
